const inputUserName1 = document.querySelector("#inputUserName1")
const inputPwd1 = document.querySelector("#inputPwd1")
var btnlogin = document.querySelector("#btnlogin")

var login = document.querySelector(".login")
var register = document.querySelector(".register")
var welcome = document.querySelector(".welcome")
var logout = document.querySelector(".logout")
var b = document.querySelector(".welcome b")

btnlogin.addEventListener('click',function(){
	const name = inputUserName1.value,
		  pwd = inputPwd1.value
		 
	utils.fetch('api/user/login.php',{name,pwd}).then(resp => {
		if(resp.code ===200){
			alert(resp.body.msg)
			b.innerHTML = name
			welcome.style.display = "inline"
			logout.style.display = "inline"
			login.style.display = "none"
			register.style.display = "none"
			
		}else{
			alert(resp.body.msg)
		}
	})
})

$('#myModal1').on('hidden.bs.modal', function (e) {
  // 当模态框被影藏之后的事件
  inputUserName1.value = inputPwd1.value = ''
})
